home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
015
/
ffutil.arc
/
MAKEPRD.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1986-03-29
|
12KB
|
562 lines
Program CvtFF;
{$B+}
{$V-}
const
MaxChar = 255;
type
DoubIntg = array[1..2] of Integer;
String80 = String[80];
tRegs = record case boolean of
false: (Ax,Bx,Cx,Dx,Bp,Si,Di,Ds,Es,Flags: Integer);
true: (Al,Ah,Bl,Bh,Cl,Ch,Dl,Dh: Byte);
end;
tFontHdr = record
C26: Integer;
CNull1: Byte;
FontType: Byte;
CNull2: Integer;
BaseLine: Integer;
Width: Integer;
Height: Integer;
Orient: Byte;
Fixed: Byte;
SymSet: Integer;
Pitch: Integer;
Points: Integer;
CNull3: Integer;
CNull4: Byte;
Style: Byte;
Weight: Byte;
TypeFace: Byte;
end;
tCharHdr = record
C4: Byte;
CNull1: Byte;
C14: Byte;
C1: Byte;
Orient: Byte;
CNull2: Byte;
LeftOffset: Integer;
TopOffset: Integer;
CWidth: Integer;
CHeight: Integer;
DeltaX: Integer;
end;
tCharEnt = record
ChNbr: Byte;
Orient: Byte;
LeftOffset: Integer;
TopOffset: Integer;
CWidth: Integer;
CHeight: Integer;
DeltaX: Integer;
end;
tFont = record
FontType: Byte;
BaseLine: Integer;
Width: Integer;
Height: Integer;
Orient: Byte;
Fixed: Byte;
SymSet: Integer;
Pitch: Integer;
Points: Integer;
Style: Byte;
Weight: Byte;
TypeFace: Byte;
Chars: array[0..MaxChar] of tCharEnt;
end;
tpFont = ^tFont;
tFName = String[40];
tMasks = array[0..7] of byte;
const
DefRegs: tRegs = (Ax:0;Bx:0;Cx:0;Dx:0;Bp:0;Si:0;Di:0;Ds:0;Es:0;Flags:0);
Masks: tMasks = ($80,$40,$20,$10,8,4,2,1);
var
FFile: Integer;
FFName: tFName;
FLen: DoubIntg;
FPos: DoubIntg;
Font: tpFont;
MinCn: Byte;
MaxCn: Byte;
Ch: Char;
function GEDoubIntg(
V1: DoubIntg;
V2: DoubIntg): Boolean;
var
Result: Boolean;
begin {GEDoubIntg}
if v1[1]>v2[1] then
Result:=true
else if v1[1]<v2[1] then
Result:=false
else if (v1[2]<0) and (v2[2]>=0) then
Result:=true
else if (v1[2]>=0) and (v2[2]<0) then
Result:=false
else
Result:= V1[2]>=V2[2];
GEDoubIntg:=Result;
end {GEDoubIntg};
procedure AddDoubIntg(
var V: DoubIntg;
Offset: Integer);
var
P1: Integer;
P2: Integer;
begin {AddDoubIntg}
P1:=V[2] and $FF;
P2:=V[2] shr 8;
P1:=P1+Offset;
P2:=P2+ (P1 shr 8);
P1:=P1 and $FF;
V[1]:=V[1] + (P2 shr 8);
P2:=P2 and $FF;
V[2]:=(P2 shl 8) + P1;
end {AddDoubIntg};
procedure CloseFont(
var FNbr: Integer);
var
Regs: tRegs;
begin {CloseFont}
if FNbr<>0 then
begin
Regs:=DefRegs;
Regs.Ah:=$3E;
Regs.Bx:=FNbr;
MsDos(Regs);
end;
FNbr:=0;
end {CloseFont};
procedure OpenFont(
Create: Boolean;
Name: tFName;
var FNbr: Integer;
var FLen: DoubIntg;
var Error: Integer);
var
Regs: tRegs;
begin {OpenFont}
Error:=0;
if FNbr<>0 then
CloseFont(FNbr);
Name[ord(Name[0])+1]:=#0;
Regs:=DefRegs;
if Create then
begin
Regs.Ax:=$3C00;
Regs.Cx:=32;
end
else
Regs.Ax:=$3D00;
Regs.Ds:=Seg(Name[1]);
Regs.Dx:=Ofs(Name[1]);
MsDos(Regs);
if odd(Regs.Flags) then
begin
Error:=Regs.Ax;
Regs.Ax:=0;
end;
FNbr:=Regs.Ax;
if not Create and (Error=0) then
begin
Regs.Ah:=$42;
Regs.Al:=2;
Regs.Bx:=FNbr;
Regs.Cx:=0;
Regs.Dx:=0;
MsDos(Regs);
FLen[1]:=Regs.Dx;
FLen[2]:=Regs.Ax;
end;
end {OpenFont};
procedure MoveFromFont(
Nbr: Integer;
FirstByte: DoubIntg;
var Dest;
Len: Integer);
var
Regs: tRegs;
begin {MoveFromFont}
Regs:=DefRegs;
with Regs do
begin
Ax:=$4200;
Bx:=Nbr;
Cx:=FirstByte[1];
Dx:=FirstByte[2];
end;
MsDos(Regs);
Regs:=DefRegs;
with Regs do
begin
Ax:=$3F00;
Bx:=Nbr;
Cx:=Len;
Dx:=Ofs(Dest);
Ds:=Seg(Dest);
end;
MsDos(Regs);
end {MoveFromFont};
procedure MoveToFont(
Nbr: Integer;
var Src;
Len: Integer);
var
Regs: tRegs;
begin {MoveToFont}
Regs:=DefRegs;
with Regs do
begin
Ax:=$4000;
Bx:=Nbr;
Cx:=Len;
Dx:=Ofs(Src);
Ds:=Seg(Src);
end;
MsDos(Regs);
end {MoveToFont};
procedure GetFontNameAndOpen(
LabelStr: String80;
Create: Boolean;
var FontName: tFName;
var FontFile: Integer;
var FLen: DoubIntg);
var
IoStatus: Integer;
DumbFile: File;
begin {GetFontNameAndOpen}
repeat
FontFile:=0;
FontName:='';
write(trm,LabelStr);
readln(trm,fontname);
if length(fontname)>0 then
begin
if Create then
begin
Assign(DumbFile,FontName);
{$I-} Erase(DumbFile); {$I+}
IoStatus:=IoResult;
end;
OpenFont(create,FontName,FontFile,FLen,IoStatus);
if iostatus<>0 then
begin
writeln(trm,^G'Open Error ',IoStatus:1);
read(kbd,ch);
if (Ch=^C) then
Halt;
end;
end
else
write(trm,^G);
until IoStatus=0;
end {GetFontNameAndOpen};
procedure GetNumber(
var Num: Integer;
var Ch: Char);
begin
num:=0;
repeat
MoveFromFont(FFile,fpos,ch,1);
if (Ch>='0') and (Ch<='9') then
begin
num:=10*num+(ord(ch)-48);
adddoubintg(fpos,1);
end;
until (Ch<'0') or (Ch>'9');
end;
procedure GetFontHeader(
var FontHdr: tFontHdr);
var
Str: String[3];
Num: Integer;
Ch: Char;
begin
MoveFromFont(FFile,fpos,str[1],3);
str[0]:=#3;
if str=^[')s' then
begin
AddDoubIntg(FPos,3);
GetNumber(Num,Ch);
AddDoubIntg(FPos,1);
MoveFromFont(FFile,FPos,FontHdr,26);
AddDoubIntg(FPos,Num);
end;
end;
procedure GetCharId(
var Cn: Byte);
var
Str: String[3];
Ch: Char;
Num: Integer;
begin
MoveFromFont(FFile,fpos,str[1],3);
str[0]:=#3;
if str=^['*c' then
begin
AddDoubIntg(FPos,3);
GetNumber(Num,Ch);
Cn:=Num;
AddDoubIntg(FPos,1);
end;
end;
procedure GetCharDef(
var CharHdr: tCharHdr);
var
Str: String[3];
Ch: Char;
Num: Integer;
begin
MoveFromFont(FFile,fpos,str[1],3);
str[0]:=#3;
if str=^['(s' then
begin
AddDoubIntg(FPos,3);
GetNumber(Num,Ch);
AddDoubIntg(FPos,1);
MoveFromFont(FFile,fpos,charhdr,16);
AddDoubIntg(FPos,Num);
end;
end;
procedure ReadFont;
var
Ch: Char;
Cn: Byte;
FontHdr: tFontHdr;
CharHdr: tCharHdr;
X: Byte;
begin {ReadFont}
for cn:=0 to maxchar do
Font^.Chars[Cn].ChNbr:=0;
GetFontNameAndOpen('Read Font: ',false,Ffname,FFile,FLen);
FPos[1]:=0;
FPos[2]:=0;
if FFile>0 then
begin
GetFontHeader(FontHdr);
Font^.FontType:=FontHdr.FontType;
Font^.BaseLine:=swap(FontHdr.BaseLine);
Font^.Width:=swap(FontHdr.Width);
Font^.Height:=swap(FontHdr.Height);
Font^.Orient:=FontHdr.Orient;
Font^.Fixed:=FontHdr.Fixed;
Font^.SymSet:=swap(FontHdr.SymSet);
Font^.Pitch:=swap(FontHdr.Pitch);
Font^.Points:=swap(FontHdr.Points);
Font^.Style:=FontHdr.Style;
Font^.Weight:=FontHdr.Weight;
Font^.TypeFace:=FontHdr.TypeFace;
mincn:=255;
maxcn:=0;
while not GEDoubIntg(FPos,FLen) do
begin
GetCharId(Cn);
GetCharDef(CharHdr);
if cn<mincn then
mincn:=cn;
if cn>maxcn then
maxcn:=cn;
write(trm,^M^['K',cn:1);
with Font^.Chars[cn] do
begin
ChNbr:=Cn;
Orient:=CharHdr.Orient;
LeftOffset:=swap(CharHdr.LeftOffset);
TopOffset:=swap(CharHdr.TopOffset);
CWidth:=swap(CharHdr.CWidth);
CHeight:=swap(CharHdr.CHeight);
DeltaX:=swap(CharHdr.DeltaX) div 4;
end;
x:=0;
while (x=0) and not GEDoubIntg(FPos,FLen) do
begin
movefromfont(FFile,FPos,X,1);
if X=0 then
AddDoubIntg(FPos,1);
end;
end;
writeln(trm);
CloseFont(FFile);
end;
end {ReadFont};
procedure WritePrd;
var
FontName:tFName;
PrdName: tFName;
Prd: text;
Cn: Byte;
Cntr: Byte;
begin {WritePrd}
write(trm,'What name should font have for MsWord? ');
readln(trm,fontname);
write(trm,'Prd name? ');
readln(trm,prdname);
assign(prd,prdname);
rewrite(prd);
writeln(prd,'{F0');
writeln(prd,'CTP:NIL');
writeln(prd,'cPSDs:1');
writeln(prd);
writeln(prd,'FontSize:',(600 div Font^.Pitch));
writeln(prd,'Wtps:W0 W0 W0 W0');
write(prd,'beginmod:0 "');
write(prd,'^[(',(font^.symset div 32):1,chr((font^.symset mod 32)+64));
write(prd,'^[(s');
if font^.fixed=0 then
write(prd,'0p',(1200.0/font^.pitch):5:2,'h')
else
write(prd,'1p');
write(prd,(72.0*(font^.points/1200.0)):5:2,'v');
write(prd,font^.style:1,'s');
write(prd,font^.weight:1,'b');
write(prd,font^.typeface:1,'T');
writeln(prd,'"');
writeln(prd,'endmod:0 "^[(st12vp10H"');
writeln(prd,'FontName:',fontname);
writeln(prd,'}F');
writeln(prd);
writeln(prd,'{W0');
writeln(prd,'FontSize:144 chFirst:',mincn:1,' chLast:',maxcn:1);
cntr:=0;
for cn:=mincn to maxcn do with Font^.Chars[Cn] do
begin
write(prd,cn:4,':');
if ChNbr<>0 then
begin
write(prd,deltax:1);
if deltax<10 then
write(prd,' ');
end
else
write(prd,'0 ');
cntr:=cntr+1;
if cntr>5 then
begin
writeln(prd);
cntr:=0;
end;
end;
if cntr>0 then
writeln(prd);
writeln(prd,'}W');
writeln(prd);
close(prd);
end {WritePrd};
begin
DefRegs.Ds:=DSeg;
DefRegs.Es:=DSeg;
new(Font);
writeln(trm,^J^J^J);
ReadFont;
WritePrd;
end.